#ifndef FORTRESS_CHARACTER_H
#define FORTRESS_CHARACTER_H
#include "glyph.h"
#include <list>

namespace fortress
{
	class items;
	class character : public glyph
	{

	private:
		friend class boost::serialization::access;
		template<class Archive>
		void serialize(Archive & ar, const unsigned int version);
		int hp;		// Health the player has
		int maxHp;	// Maximum health the player can have
		int mp;		// Magic points the player has
		int maxMp;	// Maximum magic points the player can have
		int strength;		// Strength
		int intelligence;		// Intelligence
		int dexterity;		// Dexterity
		int constitution;		// Constitution
		int charisma;		// Charisma
		int luck;		// Luck

		monster * aiController;	// We need to inform this when we die.

	protected:
		bool AI;
		std::list<items*> inventory;

		// Assign values to all major stats
		void setStats(int setStrength, int setIntelligence, int setDexterity, int setConstitution, int setCharisma, int setLuck);		
		// Use the stairs
		bool useStairs(bool upstairs);
		// Picks up the top item from the floor
		bool pickupItem();
		// Drops an item to the floor
		bool dropItem();
		// Change HP by an amount
		virtual void adjustHealth(int amt);
		// Set HP and Max HP to values.
		virtual void setHealth(int newHp, int newMaxHp=0);
	public:
		character();
		character(int setStrength, int setIntelligence, int setDexterity, int setConstitution, int setCharisma, int setLuck, bool setAI);
		virtual ~character();

		void setStrength(int setStrength){ strength = setStrength; }; //setter
		void setIntelligence(int setIntelligence){ intelligence = setIntelligence; }; //setter
		void setDexterity(int setDexterity){ dexterity = setDexterity; }; //setter
		void setConstitution(int setConstitution){ constitution = setConstitution; }; //setter
		void setCharisma(int setCharisma){ charisma = setCharisma; }; //setter
		void setLuck(int setLuck){ luck = setLuck; }; //setter
		int getStrength() const { return strength; }; //getter
		int getIntelligence() const { return intelligence; }; //getter
		int getDexterity() const { return dexterity; }; //getter
		int getConstitution() const { return constitution; }; //getter
		int getCharisma() const { return charisma; }; //getter
		int getLuck() const { return luck; }; //getter
		int getHp() const { return hp; } //getter
		int getMaxHp() const { return maxHp; } //getter

		virtual void sense(eventStructure const & sent, character const & target,  bool eyeshot, bool adjacent){ };
		bool receiveAttack(int damage);
		virtual void message(std::string const & message) { };
		bool isControlledByAI() const { return AI; };
		void setAI(monster * setAI) { aiController = setAI; };

		// A controlling instruction sent by a user interface or AI
		virtual bool exec(int, int);	
		// Run an eventStructure on the character
		virtual bool doEvent(eventStructure const & sent);
		// A move request.  Returns true if movement was performed, false otherwise
		bool move(int moveX, int moveY); 
		// Check to see if the player is dead
		bool isDead() const { return (hp<=0); };
		// Allow the character to clean up after itself
		void kill();

	};
};
#endif